package beerAgent;

public class FallingObject {
	
	public enum Direction{
		LEFT, 
		RIGHT,
		DOWN; 
	}
	
	private int length, startColumn, column, row;
	private Direction dir;
	
	public FallingObject(int maxObjectSize, int minObjectSize, int mapWidth, boolean horizontalSpeed) {
		this.startColumn = (int) (Math.random() * mapWidth - 1);
		this.column = startColumn;
		this.length = minObjectSize + (int) (Math.random() * (1 + maxObjectSize - minObjectSize));
		this.row = 0;
		
		if (horizontalSpeed) {
			int randomDir = (int) (Math.random() * 3);
			if(randomDir == 0) dir = Direction.LEFT;
			else if(randomDir == 1) dir = Direction.RIGHT;
			else dir = Direction.DOWN;
		} else{
			dir = Direction.DOWN; 
		}
	}
	
	public int getLength() {
		return length;
	}
	
	public int getStartcolumn() {
		return startColumn;
	}
	
	public int getColumn() {
		return column;
	}
	
	public int getRow() {
		return row;
	}
	
	public Direction getDirection() {
		return dir;
	}
	
	public void setRow(int row) {
		this.row = row;
	}
	
	public FallingObject copy(){
		FallingObject copy = new FallingObject(0, 0, 0,false); 
		copy.length = this.length; 
		copy.column = this.column; 
		copy.startColumn = this.startColumn; 
		copy.row =-1; 
		copy.dir = this.dir;
		return copy; 
	}
	
	public void setColumn(int column) {
		this.column = column;
	}
	
	public void reset(){
		this.column = startColumn; 
		this.row = -1;
	}
}
